package org.despair2D.ui 
{
	import flash.display.DisplayObject;
	import org.despair2D.renderer.IView;
	import org.despair2D.ui.core.Component;
	import org.despair2D.ui.core.IComponent;
	import org.despair2D.ui.DespairUI;
	import org.despair2D.debug.Logger;
	import org.despair2D.ui.core.ComponentProxy;
	import org.despair2D.ui.core.FusionComp
	import org.despair2D.ui.puppet.*;
	
	import org.despair2D.core.ns_despair
	use namespace ns_despair;
	
	/**
	 * @usage
	 * 
	 * [property]
	 * 			1. ◇numElement
	 * 			2. ◇headElement
	 * 			3. ◇tailElement
	 * 
	 * [method]
	 *			1. ◆addElement
	 * 			2. ◆addElementAt
	 * 			3. ◆getElementByName
	 * 			4. ◆getElementAt
	 * 			5. ◆setElementIndex
	 * 			6. ◆removeAllElement
	 */
public class Fusion extends ComponentProxy
{
	
	public function Fusion()
	{
		m_view = FusionComp.getFusionComp(this);
	}
	
	
	final public function get numElement() : int { return m_view.m_numElement }
	final public function get headElement() : IComponent { return m_view.headElement }
	final public function get tailElement() : IComponent { return m_view.tailElement }
	
	
	final public function addElement( c:IComponent, paddingX:Number = 0, paddingY:Number = 0, spaceCode:int = 257 ) : void 
	{
		return m_view.addElementAt(c, -1, paddingX, paddingY, spaceCode);
	}
	
	final public function addElementAt( c:IComponent, index:int, paddingX:Number = 0, paddingY:Number = 0, spaceCode:int = 257 ) : void 
	{
		return m_view.addElementAt(c, index, paddingX, paddingY, spaceCode);
	}
	
	final public function getElementByName( name:String ) : IComponent 
	{
		return m_view.getElementByName(name);
	}
	
	final public function getElementAt( index:int = 0 ) : IComponent
	{
		return m_view.getElementAt(index)
	}
	
	final ns_despair function setElementIndex( c:IComponent, index:int ) : void
	{
		m_view.setElementIndex(c, index)
	}
	
	final public function removeAllElement() : void
	{
		m_view.removeAllElement();
	}
	
	
	final override ns_despair function get view() : IView { return m_view }
	
	override ns_despair function get shell() : DisplayObject { return m_view }
	
	override ns_despair function dispose() : void
	{
		super.dispose()
		m_view.recycle()
		m_view = null
	}
	
	
	ns_despair var m_view:FusionComp
}
}